/************************************************
  * 描述: 通过序列化/反序列化宏包装
  * File: serializedata.h
  * Author: qijiangyong@mozihealthcare.cn
  * Date: 2025-09-01
  * Update:
  ***********************************************/

#ifndef SERIALIZEDATA_H
#define SERIALIZEDATA_H

#include "testdata.h"
#include <common/serialization.h>

using namespace serialize_data;

// 序列化数据
RAPIDJSON_ADAPT_STRUCT(StQtData,
						"size", &StQtData::size,
						"num", &StQtData::num,
						"type", &StQtData::type,
						"score", &StQtData::score,
						"desc", &StQtData::desc,
						"date", &StQtData::date,
						"lsdata", &StQtData::lsdata,
						"var", &StQtData::var
						)

RAPIDJSON_ADAPT_STRUCT(UploadResultData,
					   "fileId", &UploadResultData::fileId)

RAPIDJSON_ADAPT_STRUCT(UploadResult,
					   "success", &UploadResult::success,
					   "code", &UploadResult::code,
					   "msg", &UploadResult::msg,
					   "data", &UploadResult::data)

// 反序列化数据
BEGIN_DESERIALIZE_ADAPTER(StQtData)		\
	DESERIALIZE_FIELD(size)				\
	DESERIALIZE_FIELD(num)				\
	DESERIALIZE_FIELD(type)				\
	DESERIALIZE_FIELD(score)			\
	DESERIALIZE_FIELD(desc)				\
	DESERIALIZE_OPTIONAL_FIELD(date)	\
	DESERIALIZE_FIELD(lsdata)			\
	DESERIALIZE_FIELD(var)				\
END_DESERIALIZE_ADAPTER()

BEGIN_DESERIALIZE_ADAPTER(StTest)		\
	DESERIALIZE_FIELD(nnn)				\
	DESERIALIZE_FIELD(fff)				\
	DESERIALIZE_FIELD(sss)				\
END_DESERIALIZE_ADAPTER()

BEGIN_DESERIALIZE_ADAPTER(UploadResultData)	\
DESERIALIZE_FIELD(fileId)					\
END_DESERIALIZE_ADAPTER()

BEGIN_DESERIALIZE_ADAPTER(UploadResult)	\
DESERIALIZE_FIELD(success)				\
DESERIALIZE_FIELD(code)					\
DESERIALIZE_FIELD(msg)					\
DESERIALIZE_OPTIONAL_FIELD(data)		\
END_DESERIALIZE_ADAPTER()

#endif //SERIALIZEDATA_H
